/*
 * File Created: 2019-12-15 16:19:24
 * Author: 余保林 (yubaolin6@outlook.com)
 * Desc: 权限路由
 * Last Modified: 2019-12-15 16:21:14
 * Modified By: 余保林 (yubaolin6@outlook.com>)
 */

import Layout from '@/layout'

const permissionRoutes = [
  {
    path: '/equityMgt',
    component: Layout,
    meta: { title: '权益管理', icon: 'dashboard' },
    children: [
      {
        path: 'equityCategory',
        name: 'equityCategory',
        component: () => import('@/views/equityMgt/equityCategory/index'),
        meta: { title: '权益类型', icon: 'dashboard' },
        children: [
          {
            path: 'addEquityCategory',
            name: 'addEquityCategory',
            hidden: true,
            component: () =>
              import('@/views/equityMgt/equityCategory/EquityForm'),
            meta: { title: '新增权益类型', icon: 'dashboard' }
          },
          {
            path: 'editEquityCategory/:id',
            name: 'editEquityCategory',
            hidden: true,
            component: () =>
              import('@/views/equityMgt/equityCategory/EquityForm'),
            meta: { title: '编辑权益类型', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'brandMgt',
        name: 'brandMgt',
        component: () => import('@/views/equityMgt/brandMgt/index'),
        meta: { title: '品牌管理', icon: 'dashboard' },
        children: [
          {
            path: 'addBrand',
            name: 'addBrand',
            hidden: true,
            component: () => import('@/views/equityMgt/brandMgt/BrandForm'),
            meta: { title: '新增品牌', icon: 'dashboard' }
          },
          {
            path: 'editBrand/:id',
            name: 'editBrand',
            hidden: true,
            component: () => import('@/views/equityMgt/brandMgt/BrandForm'),
            meta: { title: '编辑品牌', icon: 'dashboard' }
          },
          {
            path: 'brandDetail/:id',
            name: 'brandDetail',
            hidden: true,
            component: () => import('@/views/equityMgt/brandMgt/BrandDetail'),
            meta: { title: '品牌详情', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'productMgt',
        name: 'productMgt',
        component: () => import('@/views/equityMgt/productMgt/index'),
        meta: { title: '产品管理', icon: 'dashboard' },
        children: [
          {
            path: 'addProduct',
            name: 'addProduct',
            hidden: true,
            component: () => import('@/views/equityMgt/productMgt/ProductForm'),
            meta: { title: '新增产品', icon: 'dashboard' }
          },
          {
            path: 'editProduct/:id',
            name: 'editProduct',
            hidden: true,
            component: () => import('@/views/equityMgt/productMgt/ProductForm'),
            meta: { title: '编辑产品', icon: 'dashboard' }
          },
          {
            path: 'productDetail/:id',
            name: 'productDetail',
            hidden: true,
            component: () =>
              import('@/views/equityMgt/productMgt/ProductDetail'),
            meta: { title: '产品详情', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'redeemCode',
        name: 'redeemCode',
        component: () => import('@/views/equityMgt/redeemCode/index'),
        meta: { title: '兑换码管理', icon: 'dashboard' }
      },
      {
        path: 'cinemaMgt',
        name: 'cinemaMgt',
        component: () => import('@/views/equityMgt/cinemaMgt/index'),
        meta: { title: '站点管理', icon: 'dashboard' },
        children: [
          {
            path: 'addCinema',
            name: 'addCinema',
            hidden: true,
            component: () => import('@/views/equityMgt/cinemaMgt/CinemaForm'),
            meta: { title: '新增站点', icon: 'dashboard' }
          },
          {
            path: 'editCinema/:id',
            name: 'editCinema',
            hidden: true,
            component: () => import('@/views/equityMgt/cinemaMgt/CinemaForm'),
            meta: { title: '编辑站点', icon: 'dashboard' }
          },
          {
            path: 'cinemaDetail/:id',
            name: 'cinemaDetail',
            hidden: true,
            component: () => import('@/views/equityMgt/cinemaMgt/CinemaDetail'),
            meta: { title: '站点详情', icon: 'dashboard' }
          }
        ]
      }
    ]
  },
  {
    path: '/memberMgt',
    component: Layout,
    meta: { title: '用户管理', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'memberMgt',
        hidden: true,
        component: () => import('@/views/memberMgt/index'),
        meta: { title: '用户管理', breadcrumb: false },
        children: [
          {
            path: 'memberDetail/:id',
            name: 'memberDetail',
            hidden: true,
            component: () => import('@/views/memberMgt/MemberDetail'),
            meta: { title: '用户详情', icon: 'dashboard' },
          },
          {
            path: 'memberEquityDetail/:id',
            name: 'memberEquityDetail',
            hidden: true,
            component: () => import('@/views/memberMgt/MemberEquityDetail'),
            meta: { title: '用户权益详情', icon: 'dashboard' }
          }
        ]
      }
    ]
  },
  {
    path: '/channelMgt',
    component: Layout,
    meta: { title: '渠道商管理', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'channelMgt',
        hidden: true,
        component: () => import('@/views/channelMgt/index'),
        meta: { title: '渠道商管理', breadcrumb: false },
        children: [
          {
            path: 'addChannel',
            name: 'addChannel',
            hidden: true,
            component: () => import('@/views/channelMgt/ChannelForm'),
            meta: { title: '新增渠道商' }
          },
          {
            path: 'editChannel/:id',
            name: 'editChannel',
            hidden: true,
            component: () => import('@/views/channelMgt/ChannelForm'),
            meta: { title: '编辑渠道商' }
          },
          {
            path: 'channelDetail/:id',
            name: 'channelDetail',
            hidden: true,
            component: () => import('@/views/channelMgt/ChannelDetail'),
            meta: { title: '渠道商详情' }
          }
        ]
      }
    ]
  },
  {
    path: '/orderMgt',
    component: Layout,
    redirect: '/orderMgt/equityOrderMgt',
    meta: { title: '订单管理', icon: 'dashboard' },
    children: [
      {
        path: 'equityOrderMgt',
        name: 'equityOrderMgt',
        component: () => import('@/views/orderMgt/openEquityOrderMgt/index'),
        meta: { title: '开通权益订单'},
        children: [
          {
            path: 'equityOrderDetail/:id',
            name: 'equityOrderDetail',
            hidden: true,
            component: () => import('@/views/orderMgt/openEquityOrderMgt/EquityOrderDetail'),
            meta: { title: '开通权益订单详情'}
          }
        ]
      },
      {
        path: 'movieOrderMgt',
        name: 'movieOrderMgt',
        component: () => import('@/views/orderMgt/movieOrderMgt/index'),
        meta: { title: '观影订单'},
        children: [
          {
            path: 'movieOrderDetail/:id',
            name: 'movieOrderDetail',
            hidden: true,
            component: () => import('@/views/orderMgt/movieOrderMgt/MovieOrderDetail'),
            meta: { title: '观影订单详情'}
          }
        ]
      }
    ]
  },
  {
    path: '/dealerMgt',
    component: Layout,
    meta: { title: '分销-经销商管理', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'dealerMgt',
        component: () => import('@/views/dealerMgt/index'),
        meta: { title: '分销-经销商管理', breadcrumb: false },
        hidden: true,
        children: [
          {
            path: 'addDealer',
            name: 'addDealer',
            hidden: true,
            component: () => import('@/views/dealerMgt/createDealerMgt/index'),
            meta: { title: '新增经销商'}
          },
          {
            path: 'editDealer/:id',
            name: 'editDealer',
            hidden: true,
            component: () => import('@/views/dealerMgt/createDealerMgt/index'),
            meta: { title: '编辑经销商'}
          },
          {
            path: 'dealerDetail/:id',
            name: 'dealerDetail',
            hidden: true,
            component: () => import('@/views/dealerMgt/dealerInfo/index'),
            meta: { title: '经销商信息'}
          }
        ]
      }
    ]
  },
  {
    path: '/withdrawMgt',
    component: Layout,
    meta: { title: '提现管理', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'withdrawMgt',
        component: () => import('@/views/withdrawMgt/index'),
        meta: { title: '提现管理', breadcrumb: false }
      }
    ]
  },
  {
    path: '/reportMgt',
    component: Layout,
    redirect: '/reportMgt/channelSaleEquity',
    meta: { title: '统计报表', icon: 'dashboard' },
    children: [
      {
        path: 'channelSaleEquity',
        name: 'channelSaleEquity',
        component: () => import('@/views/reportMgt/ChannelSaleEquity'),
        meta: { title: '渠道商销售权益统计'}
      },
      {
        path: 'equitySaleTotal',
        name: 'equitySaleTotal',
        component: () => import('@/views/reportMgt/equitySaleTotal/index'),
        meta: { title: '权益开通总量统计'},
        children: [
          {
            path: 'detailed',
            name: 'equitySaleDetailed',
            hidden: true,
            component: () =>
              import('@/views/reportMgt/equitySaleTotal/Detailed'),
            meta: { title: '明细'}
          }
        ]
      },
      {
        path: 'movieOrderReport',
        name: 'movieOrderReport',
        component: () => import('@/views/reportMgt/MovieOrder/index'),
        meta: { title: '观影数据统计'}
      },
      {
        path: 'exchangeCode',
        name: 'exchangeCode',
        component: () => import('@/views/reportMgt/exchangeCode/index'),
        meta: { title: '权益领取统计'},
        children: [
          {
            path: 'detailed/:date',
            name: 'exchangeCodeDetailed',
            hidden: true,
            component: () => import('@/views/reportMgt/exchangeCode/ExchangeCodeDetailed'),
            meta: { title: '明细'}
          }
        ]
      },
      {
        path: 'withdrawCount',
        name: 'withdrawCount',
        component: () => import('@/views/reportMgt/WithdrawCount'),
        meta: { title: '提现统计'}
      }
    ]
  },
  {
    path: '/interfaceMgt',
    component: Layout,
    meta: { title: '接口管理', icon: 'dashboard' },
    children: [
      {
        path: '',
        name: 'interfaceMgt',
        component: () => import('@/views/interfaceMgt/index'),
        meta: { title: '接口管理', breadcrumb: false }
      }
    ]
  },
  {
    path: '/systemMgt',
    component: Layout,
    redirect: '/systemMgt/roleMgt',
    meta: { title: '系统管理', icon: 'dashboard' },
    children: [
      {
        path: 'roleMgt',
        name: 'roleMgt',
        component: () => import('@/views/systemMgt/roleMgt/index'),
        meta: { title: '角色管理', icon: 'dashboard' },
        children: [
          {
            path: 'addRole',
            name: 'addRole',
            hidden: true,
            component: () => import('@/views/systemMgt/roleMgt/RoleForm'),
            meta: { title: '新增角色', icon: 'dashboard' }
          },
          {
            path: 'editRole',
            name: 'editRole',
            hidden: true,
            component: () => import('@/views/systemMgt/roleMgt/RoleForm'),
            meta: { title: '编辑角色', icon: 'dashboard' }
          },
          // {
          //   path: 'rolePermission/:id',
          //   name: 'rolePermission',
          //   hidden: true,
          //   component: () => import('@/views/systemMgt/roleMgt/RolePermission'),
          //   meta: { title: '分配权限', icon: 'dashboard' }
          // }
        ]
      },
      {
        path: 'userMgt',
        name: 'userMgt',
        component: () => import('@/views/systemMgt/userMgt/index'),
        meta: { title: '账号管理', icon: 'dashboard' },
        children: [
          {
            path: 'addUser',
            name: 'addUser',
            hidden: true,
            component: () => import('@/views/systemMgt/userMgt/UserForm'),
            meta: { title: '增加帐号', icon: 'dashboard' }
          },
          {
            path: 'editUser/:id',
            name: 'editUser',
            hidden: true,
            component: () => import('@/views/systemMgt/userMgt/UserForm'),
            meta: { title: '编辑帐号', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'menuMgt',
        name: 'menuMgt',
        component: () => import('@/views/systemMgt/menuMgt/index'),
        meta: { title: '菜单管理', icon: 'dashboard' },
        children: [
          {
            path: 'addMenu',
            name: 'addMenu',
            hidden: true,
            component: () => import('@/views/systemMgt/menuMgt/MenuForm'),
            meta: { title: '新增菜单', icon: 'dashboard' }
          },
          {
            path: 'editMenu',
            name: 'editMenu',
            hidden: true,
            component: () => import('@/views/systemMgt/menuMgt/MenuForm'),
            meta: { title: '编辑菜单', icon: 'dashboard' }
          }
        ]
      },
      {
        path: 'logMgt',
        name: 'logMgt',
        component: () => import('@/views/systemMgt/OperationLog'),
        meta: { title: '操作日志', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/viewing',
    component: Layout,
    redirect: '/viewing/movies',
    meta: { title: '观影信息管理', icon: 'dashboard' },
    children: [
      {
        path: 'movies',
        name: 'movies',
        component:() => import('@/views/viewing/movieMgt'),
        meta: {title: '影片信息'},
        children: [
          {
            path: 'movieDetail',
            name: 'movieDetail',
            hidden: true,
            component: () => import('@/views/viewing/movieMgt/MovieDetail'),
            meta: {title: '影片详情'},
            children: [
              {
                path: 'moviePriceEdit',
                name: 'moviePriceEdit',
                hidden: true,
                component: () => import('@/views/viewing/movieMgt/MoviePriceEdit'),
                meta: {title: '影片票价管理'}
              }
            ]
          },
          {
            path: 'movieEdit',
            name: 'movieEdit',
            hidden: true,
            component: () => import('@/views/viewing/movieMgt/MovieEdit'),
            meta: {title: '影片信息编辑'},
          }
        ]
      },
      {
        path: 'viewingData',
        name: 'viewingData',
        component: () => import('@/views/viewing/viewingData'),
        meta: {title: '观影数据'},
        children: [
          {
            path: 'viewingDetail',
            name: 'viewingDetail',
            hidden: true,
            component: () => import('@/views/viewing/viewingData/ViewingDetail'),
            meta: {title: '观影数据详情'}
          }
        ]
      }
    ]
  }
]

/**
 * 组件字典
 */
const componentMap = {}

/**
 * 生成组件字典
 */
function generateMap(routes) {
  routes.forEach(route => {
    componentMap[route.name || ''] = route.component
    if (route.children && route.children.length > 0) {
      generateMap(route.children)
    }
  })
}

generateMap(permissionRoutes)

export { componentMap }

export default permissionRoutes
